package com.springboot.jdk.colleciton;

import java.util.Iterator;
import java.util.concurrent.ArrayBlockingQueue;

/**
 * ArrayBlockingQueue Demo案例
 *
 * @author: zr
 * @date: 2021-10-14
 */
public class ArrayBlockingQueueDemo {

    public static void main(String[] args) throws InterruptedException {
        ArrayBlockingQueue<String> arrayBlockingQueue = new ArrayBlockingQueue(10);
        arrayBlockingQueue.offer("张三");
        arrayBlockingQueue.offer("李四");
        arrayBlockingQueue.offer("王五");
        System.out.println(arrayBlockingQueue.take());
        System.out.println(arrayBlockingQueue.size());

        Iterator<String> iterator = arrayBlockingQueue.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
    }
}
